package com.ruoyi.game.controller;

import cn.hutool.core.util.ObjectUtil;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.game.domain.bo.RoundNoBO;
import com.ruoyi.game.service.IRoundService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/app/game/round")
public class RoundController extends BaseController
{
    @Autowired
    private IRoundService roundService;

    /**
     * 获取当前轮次
     * @param gameType
     * @param timeLimit
     * @return
     */
    @GetMapping("/getRoundNo")
    public AjaxResult getRoundNo(int gameType, int timeLimit) throws InterruptedException {
        logger.debug("");
        RoundNoBO roundNoBO = null;
      //  for(int i = 0 ; i < timeLimit ; i++){
            roundNoBO = roundService.getRoundNo(gameType,timeLimit);
            if(ObjectUtil.isNotNull(roundNoBO)){

                return AjaxResult.success(roundNoBO);
            }
          //  Thread.sleep(300);
       // }
        return AjaxResult.error("没找到场次");
    }
}
